home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK1.toast / Development Kits (Disc 1) / QuickDraw 3D / Samples / SampleCode / Plug-in - WireFrame Renderer / SR_Rasterizers.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-14  |  33.4 KB  |  1,350 lines  |  [TEXT/MPS ]

  1. /******************************************************************************
  2.  **                                                                             **
  3.  **     Module:        SR_Rasterizers.c                                         **
  4.  **                                                                          **
  5.  **                                                                          **
  6.  **     Purpose:     Sample Renderer rasterizer routines                          **
  7.  **                                                                          **
  8.  **                                                                          **
  9.  **                                                                          **
  10.  **     Copyright (C) 1996 Apple Computer, Inc.  All rights reserved.         **
  11.  **                                                                          **
  12.  **                                                                          **
  13.  *****************************************************************************/
  14. #include "QD3D.h"
  15. #include "QD3DRenderer.h"
  16.  
  17. #include "SR.h"
  18. #include "SR_Rasterizers.h"
  19.  
  20.  
  21. /******************************************************************************
  22.  **                                                                             **
  23.  **                            Sample Renderer routines                         **
  24.  **                                                                             **
  25.  *****************************************************************************/
  26.  
  27.  
  28. /*===========================================================================*\
  29.  *
  30.  *    Routine:    SRLine_Rasterize_32()
  31.  *
  32.  *    Comments:    2D line rasterizer for 32-bit color frame buffers.
  33.  *
  34. \*===========================================================================*/
  35.  
  36. TQ3Status SRLine_Rasterize_32(
  37.     const struct TSRPrivate *srPrivate, 
  38.     const TQ3Point3D         *pt0, 
  39.     const TQ3Point3D         *pt1, 
  40.     const TQ3ColorRGB         *lineColorRGB)
  41. {
  42.     long            rowBytes;
  43.     unsigned long    *cBuffer;
  44.     float            x0, y0;
  45.     float            x1, y1;
  46.     float            dx, dy;
  47.     long            lx0, ly0;
  48.     long            lx1, ly1;
  49.     long            dlx, dly;
  50.     long            count;
  51.     unsigned long    lineColor;
  52.     
  53.     const TQ3XDrawRegionDescriptor    *descriptor;
  54.     void                            *image;
  55.     
  56.     descriptor = srPrivate->descriptor;
  57.     image = srPrivate->image;
  58.     rowBytes = descriptor->rowBytes;
  59.                 
  60.     COLOR_TO_PIXEL(
  61.         lineColor, 
  62.         srPrivate->drawRegion,
  63.         descriptor->pixelType,
  64.         lineColorRGB->r,
  65.         lineColorRGB->g,
  66.         lineColorRGB->b);
  67.  
  68.     /* Load points in device coordinates */
  69.     x0 = pt0->x;
  70.     y0 = pt0->y;
  71.     
  72.     x1 = pt1->x;
  73.     y1 = pt1->y;
  74.     
  75.     dx = x1 - x0;
  76.     dy = y1 - y0;
  77.     
  78.     /* Round points to nearest grid location */
  79.     lx0 = FLOAT_ROUND_TO_LONG_POSITIVE(x0);
  80.     ly0 = FLOAT_ROUND_TO_LONG_POSITIVE(y0);
  81.     lx1 = FLOAT_ROUND_TO_LONG_POSITIVE(x1);
  82.     ly1 = FLOAT_ROUND_TO_LONG_POSITIVE(y1);
  83.     
  84.     dlx = lx1 - lx0;
  85.     dly = ly1 - ly0;
  86.     
  87.     /* Separate X-major and Y-major cases */
  88.     if (ABS(dlx) >= ABS(dly)) {
  89.         long    xStep;
  90.         
  91.         /* X major */
  92.  
  93.         if (dx >= 0.0) {
  94.             /* Left to right */
  95.             xStep = sizeof(long);
  96.             count = lx1 - lx0 + 1;
  97.         } else {
  98.             /* Right to left */
  99.             xStep = -sizeof(long);
  100.             count = lx0 - lx1 + 1;
  101.         }
  102.  
  103.         /* Color buffer address of (lx0, ly0) */
  104.         cBuffer = (unsigned long *)((unsigned char *)image +
  105.                                     ((ly0 * rowBytes) + lx0 * sizeof(long)));
  106.  
  107.         if (ly0 == ly1) {
  108.             /* Special case: horizontal line */
  109.             do {
  110.                 *cBuffer = lineColor;
  111.                 cBuffer = (unsigned long *)((unsigned char *)cBuffer + xStep);
  112.             } while (--count);
  113.         } else {
  114.             long    fDeltaY;
  115.             long    fError;
  116.             long    yStep;
  117.  
  118.             fDeltaY = (long)
  119.                         ((float)((1 << 24) - 1) * dy / (float) (count - 1));
  120.             
  121.             if (fDeltaY >= 0) {
  122.                 /* Top to bottom */
  123.                 fError = (long)((y0 - 
  124.                             (float)ly0 + 0.5) * (float)((1 << 24) - 1));
  125.                 yStep = rowBytes;
  126.             } else {
  127.                 /* Bottom to top */
  128.                 fDeltaY = -fDeltaY;
  129.                 fError = ((1 << 24) - 1) - 
  130.                             (long)((y0 - (float)ly0 + 0.5) * (float)((1 << 24) - 1));
  131.                 yStep = -rowBytes;
  132.             }
  133.  
  134.             do {
  135.                 *cBuffer = lineColor;
  136.                 cBuffer = (unsigned long *)((unsigned char *)cBuffer + xStep);
  137.                 fError += fDeltaY;
  138.                 if (fError >= (1 << 24)) {
  139.                     fError = fError - (1 << 24);
  140.                     cBuffer = (unsigned long *)
  141.                                 ((unsigned char *)cBuffer + yStep);
  142.                 }
  143.             } while (--count);
  144.         }
  145.     } else {
  146.         long    yStep;
  147.         
  148.         /* Y major */
  149.         
  150.         if (dy >= 0.0) {
  151.             /* Top to bottom */
  152.             yStep = rowBytes;
  153.             count = ly1 - ly0 + 1;
  154.         } else {
  155.             /* Bottom to top */
  156.             yStep = -rowBytes;
  157.             count = ly0 - ly1 + 1;
  158.         }
  159.  
  160.         /* Color buffer address of (lx0, ly0) */
  161.         cBuffer = (unsigned long *)((unsigned char *)image +
  162.                                     ((ly0 * rowBytes) + lx0 * sizeof(long)));
  163.  
  164.         if (lx0 == lx1) {
  165.             /* Special case: vertical line */
  166.             do {
  167.                 *cBuffer = lineColor;
  168.                 cBuffer = (unsigned long *)((unsigned char *)cBuffer + yStep);
  169.             } while (--count);
  170.         } else {
  171.             long    fDeltaX;
  172.             long    fError;
  173.             long    xStep;
  174.  
  175.             fDeltaX = (long)
  176.                         ((float)((1 << 24) - 1) * dx / (float) (count - 1));
  177.             
  178.             if (fDeltaX >= 0) {
  179.                 /* Left to right */
  180.                 fError = (long)
  181.                             ((x0 - (float)lx0 + 0.5) * (float)((1 << 24) - 1));
  182.                 xStep = sizeof(long);
  183.             } else {
  184.                 /* Right to left */
  185.                 fDeltaX = -fDeltaX;
  186.                 fError = ((1 << 24) - 1) - 
  187.                             (long)((x0 - (float)lx0 + 0.5) * (float)((1 << 24) - 1));
  188.                 xStep = -sizeof(long);
  189.             }
  190.             
  191.             do {
  192.                 *cBuffer = lineColor;
  193.                 cBuffer = (unsigned long *)((unsigned char *)cBuffer + yStep);
  194.                 fError += fDeltaX;
  195.                 if (fError >= (1 << 24)) {
  196.                     fError = fError - (1 << 24);
  197.                     cBuffer = (unsigned long *)
  198.                                 ((unsigned char *)cBuffer + xStep);
  199.                 }
  200.             } while (--count);
  201.         }
  202.     }
  203.     
  204.     return (kQ3Success);
  205. }
  206.  
  207.  
  208. /*===========================================================================*\
  209.  *
  210.  *    Routine:    SRLine_Rasterize_32_WClip()
  211.  *
  212.  *    Comments:    2D line rasterizer with window clipping for 32-bit color 
  213.  *                frame buffers.
  214.  *
  215. \*===========================================================================*/
  216.  
  217. TQ3Status SRLine_Rasterize_32_WClip(
  218.     const struct TSRPrivate *srPrivate, 
  219.     const TQ3Point3D         *pt0, 
  220.     const TQ3Point3D         *pt1, 
  221.     const TQ3ColorRGB         *lineColorRGB)
  222. {
  223.     unsigned long    *cBuffer;
  224.     float            x0, y0;
  225.     float            x1, y1;
  226.     float            dx, dy;
  227.     long            lx0, ly0;
  228.     long            lx1, ly1;
  229.     long            dlx, dly;
  230.     long            count;
  231.     unsigned long    lineColor;
  232.     long            clipX, clipY;
  233.     TQ3Bitmap        *clipMask = NULL;
  234.     unsigned long    *clipMaskPtr, clipBits, clipXMask;
  235.     unsigned long    clipMaskRowBytes;
  236.     float            upperLeftX, upperLeftY;
  237.     const TQ3XDrawRegionDescriptor    *descriptor;
  238.     void                            *image;
  239.     long            rowBytes;
  240.  
  241.  
  242.     if (Q3XDrawRegion_GetClipMask(srPrivate->drawRegion, &clipMask) == kQ3Failure) {
  243.         return (kQ3Failure);
  244.     }
  245.     if (clipMask == NULL) {
  246.         return (kQ3Failure);
  247.     }
  248.         
  249.     descriptor = srPrivate->descriptor;
  250.     image = srPrivate->image;
  251.     rowBytes = descriptor->rowBytes;
  252.  
  253.     COLOR_TO_PIXEL(
  254.         lineColor, 
  255.         srPrivate->drawRegion,
  256.         descriptor->pixelType,
  257.         lineColorRGB->r,
  258.         lineColorRGB->g,
  259.         lineColorRGB->b);
  260.  
  261.     /* Load points in device coordinates */
  262.     x0 = pt0->x;
  263.     y0 = pt0->y;
  264.     
  265.     x1 = pt1->x;
  266.     y1 = pt1->y;
  267.     
  268.     dx = x1 - x0;
  269.     dy = y1 - y0;
  270.     
  271.     /* Set up window clipping values */
  272.     clipMaskRowBytes = clipMask->rowBytes;
  273.     Q3XDrawRegion_GetDeviceOffsetX(srPrivate->drawRegion, &upperLeftX);
  274.     Q3XDrawRegion_GetDeviceOffsetY(srPrivate->drawRegion, &upperLeftY);
  275.  
  276.     /* Round points to nearest grid location */
  277.     lx0 = FLOAT_ROUND_TO_LONG_POSITIVE(x0);
  278.     ly0 = FLOAT_ROUND_TO_LONG_POSITIVE(y0);
  279.     lx1 = FLOAT_ROUND_TO_LONG_POSITIVE(x1);
  280.     ly1 = FLOAT_ROUND_TO_LONG_POSITIVE(y1);
  281.     
  282.     dlx = lx1 - lx0;
  283.     dly = ly1 - ly0;
  284.     
  285.     /* Separate X-major and Y-major cases */
  286.     if (ABS(dlx) >= ABS(dly)) {
  287.         long    xStep;
  288.         
  289.         /* X major */
  290.  
  291.         if (dx >= 0.0) {
  292.             /* Left to right */
  293.             xStep = sizeof(long);
  294.             count = lx1 - lx0 + 1;
  295.         } else {
  296.             /* Right to left */
  297.             xStep = -sizeof(long);
  298.             count = lx0 - lx1 + 1;
  299.         }
  300.  
  301.         /* Color buffer address of (lx0, ly0) */
  302.         cBuffer = (unsigned long *)((unsigned char *)image +
  303.                                     ((ly0 * rowBytes) + lx0 * sizeof(long)));
  304.  
  305.         /* Window clip mask values */
  306.         clipX = lx0 - upperLeftX;
  307.         clipY = ly0 - upperLeftY;
  308.         clipMaskPtr = (unsigned long *)((unsigned char *)clipMask->image +
  309.                                         (clipY * clipMaskRowBytes) + ((clipX >> 5) << 2));
  310.         clipBits = *clipMaskPtr;
  311.         clipXMask = (unsigned long)(1 << (0x1f - (clipX & 0x1f))); 
  312.         
  313.         if (ly0 == ly1) {
  314.             /* Special case: horizonal line */
  315.             if (xStep > 0 ) {
  316.                 /* Left to right */
  317.                 do {
  318.                     /* Write visible pixels only */
  319.                     if (clipBits & clipXMask) {
  320.                         *cBuffer = lineColor;
  321.                     }
  322.                     
  323.                     /* Update color buffer and clip mask pointers by x step */
  324.                     cBuffer = (unsigned long *)((unsigned char *)cBuffer + xStep);
  325.                     clipXMask >>= 1;
  326.                     if (clipXMask == 0) {
  327.                         clipMaskPtr++;
  328.                         clipXMask = (unsigned long)(1 << 0x1f);
  329.                         clipBits = *clipMaskPtr;
  330.                     }
  331.                 } while (--count);
  332.             } else {
  333.                 /* Right to left */
  334.                 do {
  335.                     /* Write visible pixels only */
  336.                     if (clipBits & clipXMask) {
  337.                         *cBuffer = lineColor;
  338.                     }
  339.                     
  340.                     /* Update color buffer and clip mask pointers by x step */
  341.                     cBuffer = (unsigned long *)((unsigned char *)cBuffer + xStep);
  342.                     clipXMask <<= 1;
  343.                     if (clipXMask == 0) {
  344.                         clipMaskPtr--;
  345.                         clipXMask = 1;
  346.                         clipBits = *clipMaskPtr;
  347.                     }
  348.                 } while (--count);
  349.             }
  350.         } else {
  351.             long    fDeltaY;
  352.             long    fError;
  353.             long    yStep;
  354.             long    clipYStep;
  355.  
  356.             fDeltaY = (long)((float)((1 << 24) - 1) * dy / (float) (count - 1));
  357.             
  358.             if (fDeltaY >= 0) {
  359.                 /* Top to bottom */
  360.                 fError = (long)((y0 - (float)ly0 + 0.5) * (float)((1 << 24) - 1));
  361.                 yStep = rowBytes;
  362.                 clipYStep = clipMaskRowBytes;
  363.             } else {
  364.                 /* Bottom to top */
  365.                 fDeltaY = -fDeltaY;
  366.                 fError = ((1 << 24) - 1) - (long)((y0 - (float)ly0 + 0.5) * (float)((1 << 24) - 1));
  367.                 yStep = -rowBytes;
  368.                 clipYStep = -clipMaskRowBytes;
  369.             }
  370.  
  371.             if (xStep > 0 ) {
  372.                 /* Left to right */
  373.                 do {
  374.                     /* Write visible pixels only */
  375.                     if (clipBits & clipXMask) {
  376.                         *cBuffer = lineColor;
  377.                     }
  378.                     
  379.                     /* Update color buffer and clip mask pointers by x step */
  380.                     cBuffer = (unsigned long *)((unsigned char *)cBuffer + xStep);
  381.                     clipXMask >>= 1;
  382.                     if (clipXMask == 0) {
  383.                         clipMaskPtr++;
  384.                         clipXMask = (unsigned long)(1 << 0x1f);
  385.                         clipBits = *clipMaskPtr;
  386.                     }
  387.                     
  388.                     /* Update color buffer and clip mask pointers by y step */
  389.                     fError += fDeltaY;
  390.                     if (fError >= (1 << 24)) {
  391.                         fError = fError - (1 << 24);
  392.                         cBuffer = (unsigned long *)((unsigned char *)cBuffer + yStep);
  393.                         clipMaskPtr = (unsigned long *)((unsigned char *)clipMaskPtr + clipYStep);
  394.                         clipBits = *clipMaskPtr;
  395.                     }
  396.                 } while (--count);
  397.             } else {
  398.                 /* Right to left */
  399.                 do {
  400.                     /* Write visible pixels only */
  401.                     if (clipBits & clipXMask) {
  402.                         *cBuffer = lineColor;
  403.                     }
  404.                     
  405.                     /* Update color buffer and clip mask pointers by x step */
  406.                     cBuffer = (unsigned long *)((unsigned char *)cBuffer + xStep);
  407.                     clipXMask <<= 1;
  408.                     if (clipXMask == 0) {
  409.                         clipMaskPtr--;
  410.                         clipXMask = 1;
  411.                         clipBits = *clipMaskPtr;
  412.                     }
  413.                     
  414.                     /* Update color buffer and clip mask pointers by y step */
  415.                     fError += fDeltaY;
  416.                     if (fError >= (1 << 24)) {
  417.                         fError = fError - (1 << 24);
  418.                         cBuffer = (unsigned long *)((unsigned char *)cBuffer + yStep);
  419.                         clipMaskPtr = (unsigned long *)((unsigned char *)clipMaskPtr + clipYStep);
  420.                         clipBits = *clipMaskPtr;
  421.                     }
  422.                 } while (--count);
  423.             }
  424.         }
  425.     } else {
  426.         long    yStep;
  427.         long    clipYStep;
  428.         
  429.         /* Y major */
  430.         
  431.         if (dy >= 0.0) {
  432.             /* Top to bottom */
  433.             yStep = rowBytes;
  434.             count = ly1 - ly0 + 1;
  435.             clipYStep = clipMaskRowBytes;
  436.         } else {
  437.             /* Bottom to top */
  438.             yStep = -rowBytes;
  439.             count = ly0 - ly1 + 1;
  440.             clipYStep = -clipMaskRowBytes;
  441.         }
  442.  
  443.         /* Color buffer address of (lx0, ly0) */
  444.         cBuffer = (unsigned long *)((unsigned char *)image +
  445.                                     ((ly0 * rowBytes) + lx0 * sizeof(long)));
  446.  
  447.         /* Window clip mask values */
  448.         clipX = lx0 - upperLeftX;
  449.         clipY = ly0 - upperLeftY;
  450.         clipMaskPtr = (unsigned long *)((unsigned char *)clipMask->image +
  451.                                         (clipY * clipMaskRowBytes) + ((clipX >> 5) << 2));
  452.         clipXMask = (unsigned long)(1 << (0x1f - (clipX & 0x1f))); 
  453.         
  454.         if (lx0 == lx1) {
  455.             /* Special case: vertical line */
  456.             do {
  457.                 /* Write visible pixels only */
  458.                 if (*clipMaskPtr & clipXMask) {
  459.                     *cBuffer = lineColor;
  460.                 }
  461.                 
  462.                 /* Update color buffer and clip mask pointers by y step */
  463.                 cBuffer = (unsigned long *)((unsigned char *)cBuffer + yStep);
  464.                 clipMaskPtr = (unsigned long *)((unsigned char *)clipMaskPtr + clipYStep);
  465.             } while (--count);
  466.         } else {
  467.             long    fDeltaX;
  468.             long    fError;
  469.             long    xStep;
  470.  
  471.             fDeltaX = (long)((float)((1 << 24) - 1) * dx / (float) (count - 1));
  472.             
  473.             if (fDeltaX >= 0) {
  474.                 /* Left to right */
  475.                 fError = (long)((x0 - (float)lx0 + 0.5) * (float)((1 << 24) - 1));
  476.                 xStep = sizeof(long);
  477.  
  478.                 do {
  479.                     /* Write visible pixels only */
  480.                     if (*clipMaskPtr & clipXMask) {
  481.                         *cBuffer = lineColor;
  482.                     }
  483.                     
  484.                     /* Update color buffer and clip mask pointers by y step */
  485.                     cBuffer = (unsigned long *)((unsigned char *)cBuffer + yStep);
  486.                     clipMaskPtr = (unsigned long *)((unsigned char *)clipMaskPtr + clipYStep);
  487.                     
  488.                     /* Update color buffer and clip mask pointers by x step */
  489.                     fError += fDeltaX;
  490.                     if (fError >= (1 << 24)) {
  491.                         fError = fError - (1 << 24);
  492.                         cBuffer = (unsigned long *)((unsigned char *)cBuffer + xStep);
  493.                         clipXMask >>= 1;
  494.                         if (clipXMask == 0) {
  495.                             clipMaskPtr++;
  496.                             clipXMask = (unsigned long)(1 << 0x1f);
  497.                         }
  498.                     }
  499.                 } while (--count);
  500.             } else {
  501.                 /* Right to left */
  502.                 fDeltaX = -fDeltaX;
  503.                 fError = ((1 << 24) - 1) - (long)((x0 - (float)lx0 + 0.5) * 
  504.                             (float)((1 << 24) - 1));
  505.                 xStep = -sizeof(long);
  506.  
  507.                 do {
  508.                     /* Write visible pixels only */
  509.                     if (*clipMaskPtr & clipXMask) {
  510.                         *cBuffer = lineColor;
  511.                     }
  512.                     
  513.                     /* Update color buffer and clip mask pointers by y step */
  514.                     cBuffer = (unsigned long *)((unsigned char *)cBuffer + yStep);
  515.                     clipMaskPtr = (unsigned long *)((unsigned char *)clipMaskPtr + clipYStep);
  516.                     
  517.                     /* Update color buffer and clip mask pointers by x step */
  518.                     fError += fDeltaX;
  519.                     if (fError >= (1 << 24)) {
  520.                         fError = fError - (1 << 24);
  521.                         cBuffer = (unsigned long *)((unsigned char *)cBuffer + xStep);
  522.                         clipXMask <<= 1;
  523.                         if (clipXMask == 0) {
  524.                             clipMaskPtr--;
  525.                             clipXMask = 1;
  526.                         }
  527.                     }
  528.                 } while (--count);
  529.             }
  530.         }
  531.     }
  532.     
  533.     return (kQ3Success);
  534. }
  535.  
  536.  
  537. /*===========================================================================*\
  538.  *
  539.  *    Routine:    SRPoint_Rasterize_32()
  540.  *
  541.  *    Comments:    2D point rasterizer for 32-bit color frame buffers.
  542.  *
  543. \*===========================================================================*/
  544.  
  545. TQ3Status SRPoint_Rasterize_32(
  546.     const struct TSRPrivate *srPrivate, 
  547.     const TQ3Point3D         *pt0, 
  548.     const TQ3ColorRGB         *pointColorRGB)
  549. {
  550.     unsigned long    *cBuffer;
  551.     unsigned long    pointColor;
  552.     
  553.     const TQ3XDrawRegionDescriptor    *descriptor;
  554.     void                            *image;
  555.     long            rowBytes;
  556.  
  557.     
  558.     descriptor = srPrivate->descriptor;
  559.     image = srPrivate->image;
  560.     rowBytes = descriptor->rowBytes;
  561.  
  562.     COLOR_TO_PIXEL(
  563.         pointColor, 
  564.         srPrivate->drawRegion,
  565.         descriptor->pixelType,
  566.         pointColorRGB->r,
  567.         pointColorRGB->g,
  568.         pointColorRGB->b);
  569.  
  570.     cBuffer = (unsigned long *)((unsigned char *)image +
  571.                     ((FLOAT_ROUND_TO_LONG_POSITIVE(pt0->y) * rowBytes) + 
  572.                       FLOAT_ROUND_TO_LONG_POSITIVE(pt0->x) * sizeof(long)));
  573.  
  574.     *cBuffer = pointColor;
  575.     
  576.     return (kQ3Success);
  577. }
  578.  
  579.  
  580. /*===========================================================================*\
  581.  *
  582.  *    Routine:    SRPoint_Rasterize_32_WClip()
  583.  *
  584.  *    Comments:    2D point rasterizer with window clipping for 32-bit color 
  585.  *                frame buffers.
  586.  *
  587. \*===========================================================================*/
  588.  
  589. TQ3Status SRPoint_Rasterize_32_WClip(
  590.     const struct TSRPrivate *srPrivate, 
  591.     const TQ3Point3D         *pt0, 
  592.     const TQ3ColorRGB        *pointColorRGB)
  593. {
  594.     long                longX, longY;
  595.     float                upperLeftX, upperLeftY;
  596.     unsigned long        *cBuffer;
  597.     TQ3Bitmap            *clipMask = NULL;
  598.     unsigned long        *clipMaskPtr, clipBits, clipXMask;
  599.     unsigned long        clipMaskRowBytes;
  600.     unsigned long        pointColor;
  601.     long                rowBytes;
  602.     
  603.     const TQ3XDrawRegionDescriptor    *descriptor;
  604.     void                            *image;
  605.  
  606.     descriptor = srPrivate->descriptor;
  607.     image = srPrivate->image;
  608.     rowBytes = descriptor->rowBytes;
  609.  
  610.     COLOR_TO_PIXEL(
  611.         pointColor, 
  612.         srPrivate->drawRegion,
  613.         descriptor->pixelType,
  614.         pointColorRGB->r,
  615.         pointColorRGB->g,
  616.         pointColorRGB->b);
  617.  
  618.  
  619.     if (Q3XDrawRegion_GetClipMask(srPrivate->drawRegion, &clipMask) == kQ3Failure) {
  620.         return (kQ3Failure);
  621.     }
  622.     if (clipMask == NULL) {
  623.         return (kQ3Failure);
  624.     }
  625.  
  626.     longX = FLOAT_ROUND_TO_LONG_POSITIVE(pt0->x);
  627.     longY = FLOAT_ROUND_TO_LONG_POSITIVE(pt0->y);
  628.  
  629.     cBuffer = (unsigned long *)((unsigned char *)image +
  630.                     (((long)longY * rowBytes) + (long)longX * sizeof(long)));
  631.  
  632.     clipMaskRowBytes = clipMask->rowBytes;
  633.  
  634.     Q3XDrawRegion_GetDeviceOffsetX(srPrivate->drawRegion, &upperLeftX);
  635.     Q3XDrawRegion_GetDeviceOffsetY(srPrivate->drawRegion, &upperLeftY);
  636.     longX -= upperLeftX;
  637.     longY -= upperLeftY;
  638.  
  639.     clipMaskPtr = (unsigned long *)((unsigned char *)clipMask->image +
  640.                         (longY * clipMaskRowBytes) + ((longX >> 5) << 2));
  641.     clipBits = *clipMaskPtr;
  642.     clipXMask = (unsigned long)(1 << (0x1f - (longX & 0x1f))); 
  643.  
  644.     if (clipBits & clipXMask) {
  645.         *cBuffer = pointColor;
  646.     }
  647.     
  648.     return (kQ3Success);
  649. }
  650.  
  651.  
  652. /*===========================================================================*\
  653.  *
  654.  *    Routine:    SRLine_Rasterize_8()
  655.  *
  656.  *    Comments:    
  657.  *
  658. \*===========================================================================*/
  659.  
  660. TQ3Status SRLine_Rasterize_8(
  661.     const struct TSRPrivate *srPrivate, 
  662.     const TQ3Point3D         *pt0, 
  663.     const TQ3Point3D         *pt1, 
  664.     const TQ3ColorRGB        *lineColorRGB)
  665. {
  666.     unsigned char    *cBuffer;
  667.     float            x0, y0;
  668.     float            x1, y1;
  669.     float            dx, dy;
  670.     long            lx0, ly0;
  671.     long            lx1, ly1;
  672.     long            dlx, dly;
  673.     long            count;
  674.     unsigned char    lineColor;
  675.     long            rowBytes;
  676.     const TQ3XDrawRegionDescriptor    *descriptor;
  677.     void            *image;
  678.  
  679.     descriptor = srPrivate->descriptor;
  680.     image = srPrivate->image;
  681.     rowBytes = descriptor->rowBytes;
  682.  
  683.     COLOR_TO_PIXEL(
  684.         lineColor, 
  685.         srPrivate->drawRegion,
  686.         descriptor->pixelType,
  687.         lineColorRGB->r,
  688.         lineColorRGB->g,
  689.                    lineColorRGB->b);
  690.  
  691.     /* Load points in device coordinates */
  692.     x0 = pt0->x;
  693.     y0 = pt0->y;
  694.     
  695.     x1 = pt1->x;
  696.     y1 = pt1->y;
  697.     
  698.     dx = x1 - x0;
  699.     dy = y1 - y0;
  700.     
  701.     /* Round points to nearest grid location */
  702.     lx0 = FLOAT_ROUND_TO_LONG_POSITIVE(x0);
  703.     ly0 = FLOAT_ROUND_TO_LONG_POSITIVE(y0);
  704.     lx1 = FLOAT_ROUND_TO_LONG_POSITIVE(x1);
  705.     ly1 = FLOAT_ROUND_TO_LONG_POSITIVE(y1);
  706.     
  707.     dlx = lx1 - lx0;
  708.     dly = ly1 - ly0;
  709.     
  710.     /* Separate X-major and Y-major cases */
  711.     if (ABS(dlx) >= ABS(dly)) {
  712.         long    xStep;
  713.         
  714.         /* X major */
  715.  
  716.         if (dx >= 0.0) {
  717.             /* Left to right */
  718.             xStep = sizeof(char);
  719.             count = lx1 - lx0 + 1;
  720.         } else {
  721.             /* Right to left */
  722.             xStep = -sizeof(char);
  723.             count = lx0 - lx1 + 1;
  724.         }
  725.  
  726.         /* Color buffer address of (lx0, ly0) */
  727.         cBuffer = (unsigned char *)((unsigned char *)image +
  728.                                     ((ly0 * rowBytes) + lx0 * sizeof(char)));
  729.  
  730.         if (ly0 == ly1) {
  731.             /* Special case: horizonal line */
  732.             do {
  733.                 *cBuffer = lineColor;
  734.                 cBuffer = (unsigned char *)((unsigned char *)cBuffer + xStep);
  735.             } while (--count);
  736.         } else {
  737.             long    fDeltaY;
  738.             long    fError;
  739.             long    yStep;
  740.  
  741.             fDeltaY = (long)((float)((1 << 24) - 1) * dy / (float) (count - 1));
  742.             
  743.             if (fDeltaY >= 0) {
  744.                 /* Top to bottom */
  745.                 fError = (long)((y0 - (float)ly0 + 0.5) * (float)((1 << 24) - 1));
  746.                 yStep = rowBytes;
  747.             } else {
  748.                 /* Bottom to top */
  749.                 fDeltaY = -fDeltaY;
  750.                 fError = ((1 << 24) - 1) - (long)((y0 - (float)ly0 + 0.5) * (float)((1 << 24) - 1));
  751.                 yStep = -rowBytes;
  752.             }
  753.  
  754.             do {
  755.                 *cBuffer = lineColor;
  756.                 cBuffer = (unsigned char *)((unsigned char *)cBuffer + xStep);
  757.                 fError += fDeltaY;
  758.                 if (fError >= (1 << 24)) {
  759.                     fError = fError - (1 << 24);
  760.                     cBuffer = (unsigned char *)((unsigned char *)cBuffer + yStep);
  761.                 }
  762.             } while (--count);
  763.         }
  764.     } else {
  765.         long    yStep;
  766.         
  767.         /* Y major */
  768.         
  769.         if (dy >= 0.0) {
  770.             /* Top to bottom */
  771.             yStep = rowBytes;
  772.             count = ly1 - ly0 + 1;
  773.         } else {
  774.             /* Bottom to top */
  775.             yStep = -rowBytes;
  776.             count = ly0 - ly1 + 1;
  777.         }
  778.  
  779.         /* Color buffer address of (lx0, ly0) */
  780.         cBuffer = (unsigned char *)((unsigned char *)image +
  781.                                     ((ly0 * rowBytes) + lx0 * sizeof(char)));
  782.  
  783.         if (lx0 == lx1) {
  784.             /* Special case: vertical line */
  785.             do {
  786.                 *cBuffer = lineColor;
  787.                 cBuffer = (unsigned char *)((unsigned char *)cBuffer + yStep);
  788.             } while (--count);
  789.         } else {
  790.             long    fDeltaX;
  791.             long    fError;
  792.             long    xStep;
  793.  
  794.             fDeltaX = (long)((float)((1 << 24) - 1) * dx / (float) (count - 1));
  795.             
  796.             if (fDeltaX >= 0) {
  797.                 /* Left to right */
  798.                 fError = (long)((x0 - (float)lx0 + 0.5) * (float)((1 << 24) - 1));
  799.                 xStep = sizeof(char);
  800.             } else {
  801.                 /* Right to left */
  802.                 fDeltaX = -fDeltaX;
  803.                 fError = ((1 << 24) - 1) - (long)((x0 - (float)lx0 + 0.5) * (float)((1 << 24) - 1));
  804.                 xStep = -sizeof(char);
  805.             }
  806.             
  807.             do {
  808.                 *cBuffer = lineColor;
  809.                 cBuffer = (unsigned char *)((unsigned char *)cBuffer + yStep);
  810.                 fError += fDeltaX;
  811.                 if (fError >= (1 << 24)) {
  812.                     fError = fError - (1 << 24);
  813.                     cBuffer = (unsigned char *)((unsigned char *)cBuffer + xStep);
  814.                 }
  815.             } while (--count);
  816.         }
  817.     }
  818.  
  819.     return (kQ3Success);
  820. }
  821.  
  822.  
  823. /*===========================================================================*\
  824.  *
  825.  *    Routine:    SRLine_Rasterize_8_WClip()
  826.  *
  827.  *    Comments:    
  828.  *
  829. \*===========================================================================*/
  830.  
  831. TQ3Status SRLine_Rasterize_8_WClip(
  832.     const struct TSRPrivate *srPrivate, 
  833.     const TQ3Point3D         *pt0, 
  834.     const TQ3Point3D         *pt1, 
  835.     const TQ3ColorRGB        *lineColorRGB)
  836. {
  837.     unsigned char    *cBuffer;
  838.     float            x0, y0;
  839.     float            x1, y1;
  840.     float            dx, dy;
  841.     long            lx0, ly0;
  842.     long            lx1, ly1;
  843.     long            dlx, dly;
  844.     long            count;
  845.     unsigned char    lineColor;
  846.     long            clipX, clipY;
  847.     TQ3Bitmap        *clipMask = NULL;
  848.     unsigned long    *clipMaskPtr, clipBits, clipXMask;
  849.     unsigned long    clipMaskRowBytes;
  850.     float            upperLeftX, upperLeftY;
  851.  
  852.     long            rowBytes;
  853.     const TQ3XDrawRegionDescriptor    *descriptor;
  854.     void                            *image;
  855.  
  856.     if (Q3XDrawRegion_GetClipMask(srPrivate->drawRegion, &clipMask) == kQ3Failure) {
  857.         return (kQ3Failure);
  858.     }
  859.     if (clipMask == NULL) {
  860.         return (kQ3Failure);
  861.     }
  862.  
  863.     descriptor = srPrivate->descriptor;
  864.     image = srPrivate->image;
  865.     rowBytes = descriptor->rowBytes;
  866.     
  867.     COLOR_TO_PIXEL(
  868.         lineColor, 
  869.         srPrivate->drawRegion,
  870.         descriptor->pixelType,
  871.         lineColorRGB->r,
  872.         lineColorRGB->g,
  873.         lineColorRGB->b);
  874.  
  875.     /* Load points in device coordinates */
  876.     x0 = pt0->x;
  877.     y0 = pt0->y;
  878.     
  879.     x1 = pt1->x;
  880.     y1 = pt1->y;
  881.     
  882.     dx = x1 - x0;
  883.     dy = y1 - y0;
  884.     
  885.     /* Set up window clipping values */
  886.     clipMaskRowBytes = clipMask->rowBytes;
  887.     Q3XDrawRegion_GetDeviceOffsetX(srPrivate->drawRegion, &upperLeftX);
  888.     Q3XDrawRegion_GetDeviceOffsetY(srPrivate->drawRegion, &upperLeftY);
  889.  
  890.     /* Round points to nearest grid location */
  891.     lx0 = FLOAT_ROUND_TO_LONG_POSITIVE(x0);
  892.     ly0 = FLOAT_ROUND_TO_LONG_POSITIVE(y0);
  893.     lx1 = FLOAT_ROUND_TO_LONG_POSITIVE(x1);
  894.     ly1 = FLOAT_ROUND_TO_LONG_POSITIVE(y1);
  895.     
  896.     dlx = lx1 - lx0;
  897.     dly = ly1 - ly0;
  898.     
  899.     /* Separate X-major and Y-major cases */
  900.     if (ABS(dlx) >= ABS(dly)) {
  901.         long    xStep;
  902.         
  903.         /* X major */
  904.  
  905.         if (dx >= 0.0) {
  906.             /* Left to right */
  907.             xStep = sizeof(char);
  908.             count = lx1 - lx0 + 1;
  909.         } else {
  910.             /* Right to left */
  911.             xStep = -sizeof(char);
  912.             count = lx0 - lx1 + 1;
  913.         }
  914.  
  915.         /* Color buffer address of (lx0, ly0) */
  916.         cBuffer = (unsigned char *)((unsigned char *)image +
  917.                                     ((ly0 * rowBytes) + lx0 * sizeof(char)));
  918.  
  919.         /* Window clip mask values */
  920.         clipX = lx0 - upperLeftX;
  921.         clipY = ly0 - upperLeftY;
  922.         clipMaskPtr = (unsigned long *)((unsigned char *)clipMask->image +
  923.                                         (clipY * clipMaskRowBytes) + ((clipX >> 5) << 2));
  924.         clipBits = *clipMaskPtr;
  925.         clipXMask = (unsigned long)(1 << (0x1f - (clipX & 0x1f))); 
  926.         
  927.         if (ly0 == ly1) {
  928.             /* Special case: horizonal line */
  929.             if (xStep > 0 ) {
  930.                 /* Left to right */
  931.                 do {
  932.                     /* Write visible pixels only */
  933.                     if (clipBits & clipXMask) {
  934.                         *cBuffer = lineColor;
  935.                     }
  936.                     
  937.                     /* Update color buffer and clip mask pointers by x step */
  938.                     cBuffer = (unsigned char *)((unsigned char *)cBuffer + xStep);
  939.                     clipXMask >>= 1;
  940.                     if (clipXMask == 0) {
  941.                         clipMaskPtr++;
  942.                         clipXMask = (unsigned long)(1 << 0x1f);
  943.                         clipBits = *clipMaskPtr;
  944.                     }
  945.                 } while (--count);
  946.             } else {
  947.                 /* Right to left */
  948.                 do {
  949.                     /* Write visible pixels only */
  950.                     if (clipBits & clipXMask) {
  951.                         *cBuffer = lineColor;
  952.                     }
  953.                     
  954.                     /* Update color buffer and clip mask pointers by x step */
  955.                     cBuffer = (unsigned char *)((unsigned char *)cBuffer + xStep);
  956.                     clipXMask <<= 1;
  957.                     if (clipXMask == 0) {
  958.                         clipMaskPtr--;
  959.                         clipXMask = 1;
  960.                         clipBits = *clipMaskPtr;
  961.                     }
  962.                 } while (--count);
  963.             }
  964.         } else {
  965.             long    fDeltaY;
  966.             long    fError;
  967.             long    yStep;
  968.             long    clipYStep;
  969.  
  970.             fDeltaY = (long)((float)((1 << 24) - 1) * dy / (float) (count - 1));
  971.             
  972.             if (fDeltaY >= 0) {
  973.                 /* Top to bottom */
  974.                 fError = (long)((y0 - (float)ly0 + 0.5) * (float)((1 << 24) - 1));
  975.                 yStep = rowBytes;
  976.                 clipYStep = clipMaskRowBytes;
  977.             } else {
  978.                 /* Bottom to top */
  979.                 fDeltaY = -fDeltaY;
  980.                 fError = ((1 << 24) - 1) - (long)((y0 - (float)ly0 + 0.5) * (float)((1 << 24) - 1));
  981.                 yStep = -rowBytes;
  982.                 clipYStep = -clipMaskRowBytes;
  983.             }
  984.  
  985.             if (xStep > 0 ) {
  986.                 /* Left to right */
  987.                 do {
  988.                     /* Write visible pixels only */
  989.                     if (clipBits & clipXMask) {
  990.                         *cBuffer = lineColor;
  991.                     }
  992.                     
  993.                     /* Update color buffer and clip mask pointers by x step */
  994.                     cBuffer = (unsigned char *)((unsigned char *)cBuffer + xStep);
  995.                     clipXMask >>= 1;
  996.                     if (clipXMask == 0) {
  997.                         clipMaskPtr++;
  998.                         clipXMask = (unsigned long)(1 << 0x1f);
  999.                         clipBits = *clipMaskPtr;
  1000.                     }
  1001.                     
  1002.                     /* Update color buffer and clip mask pointers by y step */
  1003.                     fError += fDeltaY;
  1004.                     if (fError >= (1 << 24)) {
  1005.                         fError = fError - (1 << 24);
  1006.                         cBuffer = (unsigned char *)((unsigned char *)cBuffer + yStep);
  1007.                         clipMaskPtr = (unsigned long *)((unsigned char *)clipMaskPtr + clipYStep);
  1008.                         clipBits = *clipMaskPtr;
  1009.                     }
  1010.                 } while (--count);
  1011.             } else {
  1012.                 /* Right to left */
  1013.                 do {
  1014.                     /* Write visible pixels only */
  1015.                     if (clipBits & clipXMask) {
  1016.                         *cBuffer = lineColor;
  1017.                     }
  1018.                     
  1019.                     /* Update color buffer and clip mask pointers by x step */
  1020.                     cBuffer = (unsigned char *)((unsigned char *)cBuffer + xStep);
  1021.                     clipXMask <<= 1;
  1022.                     if (clipXMask == 0) {
  1023.                         clipMaskPtr--;
  1024.                         clipXMask = 1;
  1025.                         clipBits = *clipMaskPtr;
  1026.                     }
  1027.                     
  1028.                     /* Update color buffer and clip mask pointers by y step */
  1029.                     fError += fDeltaY;
  1030.                     if (fError >= (1 << 24)) {
  1031.                         fError = fError - (1 << 24);
  1032.                         cBuffer = (unsigned char *)((unsigned char *)cBuffer + yStep);
  1033.                         clipMaskPtr = (unsigned long *)((unsigned char *)clipMaskPtr + clipYStep);
  1034.                         clipBits = *clipMaskPtr;
  1035.                     }
  1036.                 } while (--count);
  1037.             }
  1038.         }
  1039.     } else {
  1040.         long    yStep;
  1041.         long    clipYStep;
  1042.         
  1043.         /* Y major */
  1044.         
  1045.         if (dy >= 0.0) {
  1046.             /* Top to bottom */
  1047.             yStep = rowBytes;
  1048.             count = ly1 - ly0 + 1;
  1049.             clipYStep = clipMaskRowBytes;
  1050.         } else {
  1051.             /* Bottom to top */
  1052.             yStep = -rowBytes;
  1053.             count = ly0 - ly1 + 1;
  1054.             clipYStep = -clipMaskRowBytes;
  1055.         }
  1056.  
  1057.         /* Color buffer address of (lx0, ly0) */
  1058.         cBuffer = (unsigned char *)((unsigned char *)image +
  1059.                                     ((ly0 * rowBytes) + lx0 * sizeof(char)));
  1060.  
  1061.         /* Window clip mask values */
  1062.         clipX = lx0 - upperLeftX;
  1063.         clipY = ly0 - upperLeftY;
  1064.         clipMaskPtr = (unsigned long *)((unsigned char *)clipMask->image +
  1065.                                         (clipY * clipMaskRowBytes) + ((clipX >> 5) << 2));
  1066.         clipXMask = (unsigned long)(1 << (0x1f - (clipX & 0x1f))); 
  1067.         
  1068.         if (lx0 == lx1) {
  1069.             /* Special case: vertical line */
  1070.             do {
  1071.                 /* Write visible pixels only */
  1072.                 if (*clipMaskPtr & clipXMask) {
  1073.                     *cBuffer = lineColor;
  1074.                 }
  1075.                 
  1076.                 /* Update color buffer and clip mask pointers by y step */
  1077.                 cBuffer = (unsigned char *)((unsigned char *)cBuffer + yStep);
  1078.                 clipMaskPtr = (unsigned long *)((unsigned char *)clipMaskPtr + clipYStep);
  1079.             } while (--count);
  1080.         } else {
  1081.             long    fDeltaX;
  1082.             long    fError;
  1083.             long    xStep;
  1084.  
  1085.             fDeltaX = (long)((float)((1 << 24) - 1) * dx / (float) (count - 1));
  1086.             
  1087.             if (fDeltaX >= 0) {
  1088.                 /* Left to right */
  1089.                 fError = (long)((x0 - (float)lx0 + 0.5) * (float)((1 << 24) - 1));
  1090.                 xStep = sizeof(char);
  1091.  
  1092.                 do {
  1093.                     /* Write visible pixels only */
  1094.                     if (*clipMaskPtr & clipXMask) {
  1095.                         *cBuffer = lineColor;
  1096.                     }
  1097.                     
  1098.                     /* Update color buffer and clip mask pointers by y step */
  1099.                     cBuffer = (unsigned char *)((unsigned char *)cBuffer + yStep);
  1100.                     clipMaskPtr = (unsigned long *)((unsigned char *)clipMaskPtr + clipYStep);
  1101.                     
  1102.                     /* Update color buffer and clip mask pointers by x step */
  1103.                     fError += fDeltaX;
  1104.                     if (fError >= (1 << 24)) {
  1105.                         fError = fError - (1 << 24);
  1106.                         cBuffer = (unsigned char *)((unsigned char *)cBuffer + xStep);
  1107.                         clipXMask >>= 1;
  1108.                         if (clipXMask == 0) {
  1109.                             clipMaskPtr++;
  1110.                             clipXMask = (unsigned long)(1 << 0x1f);
  1111.                         }
  1112.                     }
  1113.                 } while (--count);
  1114.             } else {
  1115.                 /* Right to left */
  1116.                 fDeltaX = -fDeltaX;
  1117.                 fError = ((1 << 24) - 1) - (long)((x0 - (float)lx0 + 0.5) * (float)((1 << 24) - 1));
  1118.                 xStep = -sizeof(char);
  1119.  
  1120.                 do {
  1121.                     /* Write visible pixels only */
  1122.                     if (*clipMaskPtr & clipXMask) {
  1123.                         *cBuffer = lineColor;
  1124.                     }
  1125.                     
  1126.                     /* Update color buffer and clip mask pointers by y step */
  1127.                     cBuffer = (unsigned char *)((unsigned char *)cBuffer + yStep);
  1128.                     clipMaskPtr = (unsigned long *)((unsigned char *)clipMaskPtr + clipYStep);
  1129.                     
  1130.                     /* Update color buffer and clip mask pointers by x step */
  1131.                     fError += fDeltaX;
  1132.                     if (fError >= (1 << 24)) {
  1133.                         fError = fError - (1 << 24);
  1134.                         cBuffer = (unsigned char *)((unsigned char *)cBuffer + xStep);
  1135.                         clipXMask <<= 1;
  1136.                         if (clipXMask == 0) {
  1137.                             clipMaskPtr--;
  1138.                             clipXMask = 1;
  1139.                         }
  1140.                     }
  1141.                 } while (--count);
  1142.             }
  1143.         }
  1144.     }
  1145.  
  1146.     return (kQ3Success);
  1147. }
  1148.  
  1149.  
  1150. /*===========================================================================*\
  1151.  *
  1152.  *    Routine:    SRPoint_Rasterize_8()
  1153.  *
  1154.  *    Comments:    
  1155.  *
  1156. \*===========================================================================*/
  1157.  
  1158. TQ3Status SRPoint_Rasterize_8(
  1159.     const struct TSRPrivate *srPrivate, 
  1160.     const TQ3Point3D         *pt0, 
  1161.     const TQ3ColorRGB        *pointColorRGB)
  1162. {
  1163.     unsigned char    *cBuffer;
  1164.     unsigned char    pointColor;
  1165.     long                            rowBytes;
  1166.     const TQ3XDrawRegionDescriptor    *descriptor;
  1167.     void                            *image;
  1168.  
  1169.     descriptor = srPrivate->descriptor;
  1170.     image = srPrivate->image;
  1171.     rowBytes = descriptor->rowBytes;
  1172.  
  1173.     COLOR_TO_PIXEL(
  1174.         pointColor, 
  1175.         srPrivate->drawRegion,
  1176.         descriptor->pixelType,
  1177.         pointColorRGB->r,
  1178.         pointColorRGB->g,
  1179.         pointColorRGB->b);
  1180.  
  1181.     cBuffer = (unsigned char *)((unsigned char *)image +
  1182.         ((FLOAT_ROUND_TO_LONG_POSITIVE(pt0->y) * rowBytes) + 
  1183.           FLOAT_ROUND_TO_LONG_POSITIVE(pt0->x) * sizeof(char)));
  1184.  
  1185.     *cBuffer = (unsigned char)pointColor;
  1186.  
  1187.     return (kQ3Success);
  1188. }
  1189.  
  1190.  
  1191. /*===========================================================================*\
  1192.  *
  1193.  *    Routine:    SRPoint_Rasterize_8_WClip()
  1194.  *
  1195.  *    Comments:    
  1196.  *
  1197. \*===========================================================================*/
  1198.  
  1199. TQ3Status SRPoint_Rasterize_8_WClip(
  1200.     const struct TSRPrivate *srPrivate, 
  1201.     const TQ3Point3D         *pt0, 
  1202.     const TQ3ColorRGB         *pointColorRGB)
  1203. {
  1204.     long            longX, longY;
  1205.     float            upperLeftX, upperLeftY;
  1206.     unsigned char    *cBuffer;
  1207.     TQ3Bitmap        *clipMask = NULL;
  1208.     unsigned long    *clipMaskPtr, clipBits, clipXMask;
  1209.     unsigned long    clipMaskRowBytes;
  1210.     unsigned char    pointColor;
  1211.     
  1212.     long                            rowBytes;
  1213.     const TQ3XDrawRegionDescriptor    *descriptor;
  1214.     void                            *image;
  1215.  
  1216.  
  1217.     if (Q3XDrawRegion_GetClipMask(srPrivate->drawRegion, &clipMask) == kQ3Failure) {
  1218.         return (kQ3Failure);
  1219.     }
  1220.     if (clipMask == NULL) {
  1221.         return (kQ3Failure);
  1222.     }
  1223.  
  1224.     descriptor = srPrivate->descriptor;
  1225.     image = srPrivate->image;
  1226.     rowBytes = descriptor->rowBytes;
  1227.  
  1228.     COLOR_TO_PIXEL(
  1229.         pointColor,
  1230.         srPrivate->drawRegion,
  1231.         descriptor->pixelType,
  1232.         pointColorRGB->r,
  1233.         pointColorRGB->g,
  1234.         pointColorRGB->b);
  1235.  
  1236.     longX = FLOAT_ROUND_TO_LONG_POSITIVE(pt0->x);
  1237.     longY = FLOAT_ROUND_TO_LONG_POSITIVE(pt0->y);
  1238.  
  1239.     cBuffer = (unsigned char *)((unsigned char *)image +
  1240.         (((long)longY * rowBytes) + (long)longX * sizeof(char)));
  1241.  
  1242.     clipMaskRowBytes = clipMask->rowBytes;
  1243.  
  1244.     Q3XDrawRegion_GetDeviceOffsetX(srPrivate->drawRegion, &upperLeftX);
  1245.     Q3XDrawRegion_GetDeviceOffsetY(srPrivate->drawRegion, &upperLeftY);
  1246.     longX -= upperLeftX;
  1247.     longY -= upperLeftY;
  1248.  
  1249.     clipMaskPtr = (unsigned long *)((unsigned char *)clipMask->image +
  1250.         (longY * clipMaskRowBytes) + ((longX >> 5) << 2));
  1251.     clipBits = *clipMaskPtr;
  1252.     clipXMask = (unsigned long)(1 << (0x1F - (longX & 0x1F))); 
  1253.  
  1254.     if (clipBits & clipXMask) {
  1255.         *cBuffer = (unsigned char)pointColor;
  1256.     }
  1257.  
  1258.     return (kQ3Success);
  1259. }
  1260.  
  1261.  
  1262. /*===========================================================================*\
  1263.  *
  1264.  *    Routine:    SRLine_Rasterize_Null()
  1265.  *
  1266.  *    Comments:    
  1267.  *
  1268. \*===========================================================================*/
  1269.  
  1270. TQ3Status SRLine_Rasterize_Null(
  1271.     const struct TSRPrivate *srPrivate, 
  1272.     const TQ3Point3D         *pt0, 
  1273.     const TQ3Point3D         *pt1, 
  1274.     const TQ3ColorRGB        *lineColorRGB)
  1275. {
  1276.     UNUSED(srPrivate);
  1277.     UNUSED(pt0);
  1278.     UNUSED(pt1);
  1279.     UNUSED(lineColorRGB);
  1280.  
  1281.     return (kQ3Success);
  1282. }
  1283.  
  1284.  
  1285. /*===========================================================================*\
  1286.  *
  1287.  *    Routine:    SRPoint_Rasterize_Null()
  1288.  *
  1289.  *    Comments:    
  1290.  *
  1291. \*===========================================================================*/
  1292.  
  1293. TQ3Status SRPoint_Rasterize_Null(
  1294.     const struct TSRPrivate *srPrivate, 
  1295.     const TQ3Point3D         *pt0, 
  1296.     const TQ3ColorRGB        *pointColorRGB)
  1297. {
  1298.     UNUSED(srPrivate);
  1299.     UNUSED(pt0);
  1300.     UNUSED(pointColorRGB);
  1301.  
  1302.     return (kQ3Success);
  1303. }
  1304.  
  1305.  
  1306. /*===========================================================================*\
  1307.  *
  1308.  *    Routine:    SRMarker_Rasterize_Null()
  1309.  *
  1310.  *    Comments:    
  1311.  *
  1312. \*===========================================================================*/
  1313.  
  1314. TQ3Status SRMarker_Rasterize_Null(
  1315.     const struct TSRPrivate     *srPrivate, 
  1316.     const TQ3Point3D             *pt0, 
  1317.     const TSRMarkerRasterData    *bitmap, 
  1318.     const TQ3ColorRGB            *pointColorRGB)
  1319. {
  1320.     UNUSED(srPrivate);
  1321.     UNUSED(pt0);
  1322.     UNUSED(bitmap);
  1323.     UNUSED(pointColorRGB);
  1324.  
  1325.     return (kQ3Success);
  1326. }
  1327.  
  1328.  
  1329. /*===========================================================================*\
  1330.  *
  1331.  *    Routine:    SRPixmapMarker_Rasterize_Null()
  1332.  *
  1333.  *    Comments:    
  1334.  *
  1335. \*===========================================================================*/
  1336.  
  1337. TQ3Status SRPixmapMarker_Rasterize_Null(
  1338.     const struct TSRPrivate     *srPrivate, 
  1339.     const TQ3Point3D                 *pt0, 
  1340.     const TSRPixmapMarkerRasterData    *pixmap,
  1341.     const TQ3ColorRGB                *highlightColor)
  1342. {
  1343.     UNUSED(srPrivate);
  1344.     UNUSED(pt0);
  1345.     UNUSED(pixmap);
  1346.     UNUSED(highlightColor);
  1347.  
  1348.     return (kQ3Success);
  1349. }
  1350.